/****************************************************************************/
/*
* api parse xml rom to ram & store xml ram to rom.
*/
/****************************************************************************/
#ifndef __PDM_T3VTW85S
#define __PDM_T3VTW85S

#define CMS_PDM_MAX_MESSAGE_LEN 8192 //modified to two max_message_len for digitmap support 8k bytes  
#define CMS_PDM_MAX_NODE_NAME_LEN 64

/*definitions of indexNodeFlagList_t's flag*/
#define CMS_PDM_INDEXCHILD_CONFIGURED	1
#define CMS_PDM_CHILDOFINDEX_CONFIGURED	2
#define CMS_PDM_PARSE_CHILD_I			3

#define MAX_EXPAND_SIZE 6 /* strlen("&quot;") */
#define QUOT "&quot;" /* " */
#define APOS "&apos;" /* ' */
#define LT   "&lt;"   /* < */
#define GT   "&gt;"   /* > */
#define AMP  "&amp;"  /* & */

#define NODE_DEL(head, node)	\
	{	if(node->next) node->next->prev=node->prev;	\
		if(node->prev) node->prev->next=node->next;	\
		else head=node->next;				\
	}

#define NODE_ADD(head, node)	\
	{	node->next=head;		\
		node->prev=NULL;		\
		if(head) (head)->prev=node;	\
		head=node;			\
	}

typedef struct indexNodeFlagList_s{
	struct indexNodeFlagList_s *next;
	int flag;
}indexNodeFlagList_t;

typedef struct typeTable_s {
	uint32_t	recType;	/* record type			*/
	char	*name;		/* memory map table 	*/
} typeTable_t;
/*
typedef struct cmsParentList_s{
	struct parentList_s *next;
	struct objectNode_t *node;
	int flag;
}cmsParentList_t;
*/
typedef struct tagNode_s{
	struct tagNode_s *next;
	struct tagNode_s *prev;
	int prevState;
	int parameterFlag;
	char name[CMS_PDM_MAX_NODE_NAME_LEN];
}tagNode_t;


typedef struct parameterList_s{
	struct parameterList_s *next;
	struct parameterList_s *prev;
	char *value;
	uint32_t type;
	uint64_t maxValue;
	uint64_t minValue;
	uint32_t length;
	uint32_t attrValue;
	uint16_t attrExtValue;
	char *name;
}parameterList_t;

typedef struct attrList_s{
	uint32_t type;
	uint32_t length;
	uint32_t attrValue;
	uint16_t attrExtValue;
	int nodeNumber;			//index node support max child num
	int paraFlag;			//1, current xml line is parameter line;
	int configFlag;			//1, parameter value is configed; 0, parameter value is nonconfiged
	uint64_t maxValue;
	uint64_t minValue;
	//char name[CMS_PDM_MAX_NODE_NAME_LEN];
	uint32_t priValue;
	uint32_t updateObjFlag;
}attrList_t;

typedef struct userData_s{
	int state;
	char *parameterNamePtr;					//current parameter's name
	
	/*Used to save content*/
	int contentFlag;
	int checkContentFlag;
	char *text;								//parameter value 
	int textlen;							//parameter value length
	int nodeToParaFlag;						//parse node line or parametere line
	int parameterNum;						//current node parameter num
	struct tagNode_s *tagStack;
	struct parameterList_s *parameterList;	//current node parameter list
	struct parentList_s *parentList;		//current parent node list

	/* Used for settings tree */
	struct objectNode_s *configHead;		//first node when parse xml
	struct objectNode_s *configCurrent;		//current node when parse xml
	uint64_t currentIA;						//current object's IA
	cmsoffset_t currentOffset;				//current node's offset
}userData_t;


#endif /* end of include guard: __PDM_T3VTW85S */
